package cz.muni.fi.pa165.pa165_spring.convert;

import cz.muni.fi.pa165.pa165_spring.dao.PlayerDAO;
import cz.muni.fi.pa165.pa165_spring.dto.PlayerDTO;
import cz.muni.fi.pa165.pa165_spring.model.Player;
import org.springframework.beans.factory.annotation.Autowired;

public class PlayerConvert {

    @Autowired
    PlayerDAO playerDao;
    
    public PlayerDTO fromEntityToDTO(Player player) {
        if(player == null) {
            throw new IllegalArgumentException("Player entity is null.");
        }
        
        PlayerDTO dtoPlayer = new PlayerDTO();
        
        dtoPlayer.setId(player.getId());
        dtoPlayer.setName(player.getName());
        dtoPlayer.setSurname(player.getSurname());
        dtoPlayer.setAge(player.getAge());
        dtoPlayer.setHeight(player.getHeight());
        dtoPlayer.setWeight(player.getWeight());
        
        return dtoPlayer;
    }

    public Player fromDTOToEntity(PlayerDTO dto) {
        Player player = new Player();
        
        player.setId(dto.getId());
        player.setName(dto.getName());
        player.setSurname(dto.getSurname());
        player.setAge(dto.getAge());
        player.setHeight(dto.getHeight());
        player.setWeight(dto.getWeight());
        
        return player;
    }
    
}
